Effect={};

function Effect:new(...)
    return ClassUtils:extends(Effect, Display, ...);
end

function Effect:ctor(...)
    self.effectRoot = nil;
    self.scale = nil;
    self.originalScale = nil;
    self.isUIEffect = nil;
    Display.ctor(self,...);
end

function Effect:show(prefabPath,parent,isUIEffect,scale)
    if self.isInit then
        self:setVisible(true);
        return; 
    end
    if not self.effectRoot then
        self.effectRoot=GameObject("EffectRoot");
    end
    if not isUIEffect then
        isUIEffect=false;    
    end
    self.isUIEffect = isUIEffect;
    if not scale then
        scale = Vector3.one;
    end
    self.scale=scale;
    self.effectRoot.transform:SetParent(parent.transform, false);
    self:setParent(self.effectRoot);
    self:setPrefabPath("Effect/"..prefabPath);
    self:loadPrefab();
end

function Effect:onStart()
    self.originalScale = self.gameObject.transform.localScale;
    self:setScale(self.scale);
    if self.isUIEffect then
        self:setZ(-300);
    end
end

function Effect:setZ(z)
    if self.effectRoot then
        self.effectRoot.transform.localPosition = Vector3(0, 0, z);
    end
end

function Effect:setScale(v3)
    self.scale = v3;
    if self.isInit then
        self.gameObject.transform.localScale = 
            Vector3(self.originalScale.x*v3.x, self.originalScale.y*v3.y, self.originalScale.z*v3.z);
    end
end